<?php
session_start();
require_once("./config/include.inc.php");
$sql = "";
	
//获取form值
$action = $_POST["action"];	
$transID = $_POST["id"];
$order_id = $_POST["order_id"];	
$chinese_content = $_POST["chinese_content"];
$english_content = $_POST["english_content"];
$japanese_content = $_POST["japanese_content"];
$trans_type = $_POST["trans_type"];
$trans_type_1 = "";
$trans_type_2 = "";
$trans_type_3 = "";

$currentTitle = "新增翻译";
if($action == "add"){
	$currentTitle = "新增翻译";
}else if($action == "edit"){
	$currentTitle = "编辑翻译";
	$sql_select = "SELECT * from translate t where t.id = $transID ";
	$result = $db->Execute($sql_select);
	while (!$result->EOF) {
		$order_id = $result->fields['order_id'];
		$chinese_content = $result->fields['chinese_content'];
		$english_content = $result->fields['english_content'];
		$japanese_content = $result->fields['japanese_content'];
		$trans_type = $result->fields['type'];
		$result->MoveNext();
	}
	echo "编辑内容 ID:$transID";
}else if($action == "save"){	
	if($transID == ""){
		$currentTitle = "新增翻译成功!";
		$sql = "INSERT INTO translate (order_id,chinese_content,english_content,japanese_content,type) VALUES ($order_id,'$chinese_content','$english_content','$japanese_content',$trans_type)";
		$db->Execute($sql);	
	}else{
		$currentTitle = "修改翻译成功!";
		$sql = "update translate set order_id=$order_id,chinese_content='$chinese_content',english_content='$english_content',japanese_content='$japanese_content',type=$trans_type   where id=".$transID;
		$db->Execute($sql);
	}	
	$showSuccess = "***************************************<br>";
	$showSuccess = $showSuccess."OrderID:".$order_id."<br>";
	$showSuccess = $showSuccess."中文内容:".$chinese_content."<br>";
	$showSuccess = $showSuccess."英文内容:".$english_content."<br>";
	$showSuccess = $showSuccess."日文内容:".$japanese_content."<br>";
	$showSuccess = $showSuccess."内容类型:".$trans_type."<br>";
	$showSuccess = $showSuccess."***************************************<br>";
	echo $showSuccess;

	
}


if($trans_type == "1"){
	$trans_type_1 =  "selected";
}else if($trans_type == "2"){
	$trans_type_2 =  "selected";
}else if($trans_type == "3"){
	$trans_type_3 =  "selected";
}else{
	$trans_type_1 =  "selected";
}

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<head>

<link rel="shortcut icon" href="/vincent/images/favicon.ico" type="image/x-icon" />
<link href="/vincent/common/main.css" media="all" rel="stylesheet" type="text/css" />

<script src="/vincent/common/jquery-1.6.4.min.js" type="text/javascript"></script>



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="keywords" content="" />
<meta name="description" content="" />

<title>Translate</title>

</head> 
<!--End:head-->


<body>
<form name="inputTransForm" action="trans-input.php" method="post">
<div>
<h1><?php echo $currentTitle;?></h1>	
</div>	


<div class="grayTable">	
<table >
	<tr>
		<td align="right">OrderID:</td>
		<td align="left"><input type="text" name="order_id" id="order_id" size=5 value="<?php echo $order_id; ?>"></td>
	</tr>			
	<tr>
		<td align="right">中文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="chinese_content" name="chinese_content" ><?php echo $chinese_content; ?></textarea>
		</td>
	</tr>	
	<tr>
		<td align="right">英文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="english_content" name="english_content" ><?php echo $english_content; ?></textarea>
		</td>
	</tr>
	<tr>
		<td align="right">日文内容:</td>
		<td align="left">
			<textarea cols="100" rows="5" id="japanese_content" name="japanese_content" ><?php echo $japanese_content; ?></textarea>
		</td>
	</tr>
	<tr>
		<td align="right">内容类型:</td>
		<td align="left">
		<select name="trans_type" id="trans_type">
			<option value=1  <?php echo $trans_type_1; ?>>邮件翻译</option>
			<option value=2  <?php echo $trans_type_2; ?>>短文翻译</option>
			<option value=3  <?php echo $trans_type_3; ?>>长段翻译</option>
		</select>
		</td>
	</tr>
	<tr>
		<td colspan=2 align="right"><input type="submit" value="保存"></td>
	</tr>					
</table>
<br>
<a href="trans-list.php">翻译列表</a>
</div>

<input type="hidden" name="id" id="id" value="<?php echo $transID;?>">	
<input type="hidden" name="action" id="action" value="save">
</form>

</body>

</html>



<script>
</script>